// pages/addresssubscription_coll/subscription_coll.js
import baseuser from '~/utils/users.js'
Page({

    /**
     * 页面的初始数据
     */
    data: {
        active: 0,
        "pages": "1",
        storeName: "",
        indexlist:[],
    },
    inputchange(items) {
        this.setData({
            storeName: items.detail
        })
    },
    onChange(items) {
        this.setData({
            active: items.detail.index,
            pages:1
        })
        if (this.data.active == 0) {
            this.getonelist()
        }
        if (this.data.active == 1) {
            this.gettwolist()
        }
        if (this.data.active == 2) {
            this.getshreelist()
        }
        
    },
    getSearch(){
      if (this.data.active == 0) {
        this.getonelist()
    }
    if (this.data.active == 1) {
        this.gettwolist()
    }
    if (this.data.active == 2) {
        this.getshreelist()
    }
    },
    getQSearch(){
      this.setData({
        value: '',
        // indexlist:[]
    })
    },
    async getonelist() {
        let reqdata = {
            "page": this.data.pages,
            "pageSize": "10",
            "storeName": this.data.storeName,
        }
        let resdata = await baseuser.getmyfollow(reqdata)
        if (resdata.code == 200) {
            this.setData({
                indexlist: resdata.data.data.items.records
            })
            if(this.data.indexlist.length==0){
              wx.showToast({
                title: '暂无数据！',
                icon: 'none',
                duration: 2000
            });
            }
           
        } else {
            wx.showToast({
                title: '查询失败',
                icon: 'none',
                duration: 2000
            })
        }
    },
    async gettwolist() {
        let reqdata = {
            "page": this.data.pages,
            "pageSize": "10",
            "storeName": this.data.storeName,
        }
        let resdata = await baseuser.getmyrecord(reqdata)
        if (resdata.code == 200) {
            this.setData({
                indexlist: resdata.data.data.items.records
            })
        } else {
            wx.showToast({
                title: '查询失败',
                icon: 'none',
                duration: 2000
            })
        }
    },
    async getshreelist() {
        let reqdata = {
            "page": this.data.pages,
            "pageSize": "10",
            "storeName": this.data.storeName,
        }
        let resdata = await baseuser.getmyapplet(reqdata)
        if (resdata.code == 200) {
            this.setData({
                indexlist: resdata.data.data.items.records
            })
        } else {
            wx.showToast({
                title: '查询失败',
                icon: 'none',
                duration: 2000
            })
        }
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        this.getonelist()
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})